import request from "@/utils/request";

// 品牌列表每个数据的类型
export interface TrademarkItemType {
  id?: number;
  tmName: string;
  logoUrl: string;
}

// 品牌列表的数据类型
export type TrademarkListType = TrademarkItemType[];

// 请求商品列表返回值类型
interface reqTrademarkReturnType {
  records: TrademarkListType;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}

// 请求商品列表
export const reqGetTrademarkList = (page: number, limit: number) => {
  return request.get<null, reqTrademarkReturnType>(
    `/admin/product/baseTrademark/${page}/${limit}`
  );
};

// 请求新增品牌
export const reqAddTrademark = (tmInfo: TrademarkItemType) => {
  return request.post<null, null>(`/admin/product/baseTrademark/save`, tmInfo);
};

// 请求修改品牌
export const reqUpdataTrademark = (tmInfo: TrademarkItemType) => {
  return request.put(`/admin/product/baseTrademark/update`, tmInfo);
};

// 请求删除品牌
export const reqDeleteTrademark = (id: number) => {
  return request.delete(`/admin/product/baseTrademark/remove/${id}`);
};

// 品牌数据类型
export interface TrademarkInfoType {
  id: number;
  tmName: string;
  logoUrl: string;
}

// 所有品牌信息列表类型
export type AllTrademarkListType = TrademarkInfoType[];

// 请求所有品牌数据
export const reqGetAllTrademarkList = () => {
  return request.get<null, AllTrademarkListType>(
    `/admin/product/baseTrademark/getTrademarkList`
  );
};
